package com.vf.admin.client.dao;

import com.vf.admin.common.db.BaseDao;
import com.vf.admin.common.splitpage.SplitPageBean;
import com.vf.admin.miaodong.entity.AppOrder;
import com.vf.admin.miaodong.entity.VipOrder;
import com.vf.admin.utils.StringEx;
import org.springframework.stereotype.Repository;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;

@Repository
public class VipOrderDao extends BaseDao<VipOrder> {

    public List<VipOrder> page(Map<String, Object> paraMap, SplitPageBean splitPage) {
        ArrayList<Object> paramList = new ArrayList<>();
        StringBuilder sbStr = new StringBuilder("select * from vip_order where 1=1");

        String sql = sbStr.toString();
        return this.queryList(sql, paramList, VipOrder.class, splitPage);
    }

    public List<VipOrder> list() {
        StringBuilder sbStr = new StringBuilder("select * from vip_order order by num asc");

        String sql = sbStr.toString();
        return this.queryList(sql, new ArrayList<>(), VipOrder.class);
    }

    public VipOrder infoByOrderNo(String orderNo) {
        ArrayList<Object> paramList = new ArrayList<>();
        StringBuilder sbStr = new StringBuilder("select * from vip_order where orderNo=?");
        paramList.add(orderNo);
        String sql = sbStr.toString();
        return this.queryObj(sql, paramList, VipOrder.class);
    }

    public VipOrder getByOrderNum(String orderNo, Integer type, Integer status) {
        if (StringEx.isNull(orderNo)) {
            return null;
        }
        List<Object> paramList = new ArrayList<Object>();
        StringBuilder sbStr = new StringBuilder("select * from vip_order where orderNo = ? ");
        paramList.add(orderNo);
        sbStr.append(" and type = ? ");
        paramList.add(type);
        sbStr.append(" and status = ? ");
        paramList.add(status);
        String sql = sbStr.toString();
        return this.queryObj(sql, paramList, VipOrder.class);
    }
}
